<?php
/*parameters
 * first - categoryAlias
 * second - articleAlias
 */
require_once("class/bpArticles.class.php");
if (isset($_REQUEST["second"])) {
    require_once("class/bpTag.class.php");
    $categoryAlias = $_REQUEST["first"];
    $articleAlias = $_REQUEST["second"];
    $aCategory = bpArticles::getCategories($categoryAlias, true);
    $aArticle = bpArticles::getArticleByAlias($articleAlias);
    if ($aTags = bpTag::getTagsMaterial($aArticle["id"], MATERIAL_TYPE_ARTICLE)) {
        $smarty->assign("aTags", $aTags);
    }
    $smarty->assign("aArticle", $aArticle);
    $smarty->display("articles/articles_article.tpl");
    
} elseif (isset($_REQUEST["first"])) {
    $categoryAlias = $_REQUEST["first"];
    $aCategory = bpArticles::getCategories($categoryAlias, true);
    $aArticles = bpArticles::getArticlesByCategory($aCategory["id"]);
    $smarty->assign("aCategory", $aCategory);
    $smarty->assign("aArticles", $aArticles);
    $smarty->display("articles/articles_category.tpl");
} else {
    $aCategories = bpArticles::getCategories();
    $smarty->assign("aCategories", $aCategories);
    $smarty->display("articles/articles_categories.tpl");
}
?>